import styles from './index.module.scss'

type Props = {
  hideList: () => void
  onUpdate: (key: string, value: string) => void
  type: '' | 'photo' | 'gender'
}
const genderList = [{ title: '男', value: '0' }, { title: '女', value: '1' }]
const photoList = [{ title: '拍照', value: '0' }, { title: '本地选择', value: '1' }]

const EditList = ({ hideList, type, onUpdate }: Props) => {
  const list = type === 'photo' ? photoList : genderList

  return (
    <div className={styles.root}>
      {list.map((item) => (
        <div
          key={item.value}
          onClick={() => onUpdate(type, item.value)}
          className="list-item">
          {item.title}
        </div>
      ))}

      <div className="list-item" onClick={hideList}>
        取消
      </div>
    </div>
  )
}

export default EditList
